import request from '@/utils/request.js';

/**
 * 登录业务
 * @param loginData
 */
export const userLoginService = (loginData) => {
    return request.post('/user/login' , loginData);
}

/**
 * 注册业务
 * @param registerData
 */
export const userRegisterService = (registerData) => {
    return request.post('/user/register' , registerData);
}

/**
 * 修改用户信息
 */
export const userUpdateService = (userInfo) => {
    return request.put('/user/updateUser' , userInfo);
}

/**
 * 修改用户密码
 */
export const userUpdatePwdService = (pwdInfo) => {
    return request.put('/user/updatePassword' , pwdInfo);
}

/**
 * 获取用户所有收货地址
 */
export const userGetAllAddressService = () => {
    return request.get('/address');
}

/**
 * 修改用户收货地址
 */
export const userUpdateAddressService = (addressInfo) => {
    return request.put('/address' , addressInfo);
}

/**
 * 设置默认收货地址
 */
export const userSetDefaultAddressService = (addressId) => {
    return request.put(`/address/setDefault/${addressId}`);
}

/**
 * 取消设置默认收货地址
 */
export const userCancelDefaultAddressService = (addressId) => {
    return request.put(`/address/cancelDefault/${addressId}`);
}

/**
 * 删除用户收货地址
 */
export const userDeleteAddressService = (addressId) => {
    return request.delete(`/address/${addressId}`);
}

/**
 * 添加用户收货地址
 */
export const userAddAddressService = (addressInfo) => {
    return request.post('/address' , addressInfo);
}

/**
 * 退出登录业务
 */
export const userLogOutService = () => {
    return request.post('/user/logout');
}
